home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / pcl4p51.zip / MINIMAL.PAS < prev    next >
Pascal/Delphi Source File  |  1996-06-04  |  2KB  |  63 lines

  1. (*********************************************)
  2. (*                                           *)
  3. (*          MINIMAL.PAS     April 95         *)
  4. (*                                           *)
  5. (*********************************************)
  6.  
  7.  
  8. program minimal;
  9. uses crt, PCL4P;
  10.  
  11. var
  12.    RetCode : Integer;
  13.    Byte    : Char;
  14.    Port    : Integer;
  15.    BufPtr  : Pointer;
  16.    BufSeg  : Integer;
  17.  
  18. begin   (* main program *)
  19.    (* setup 1K receive buffer *)
  20.    GetMem(BufPtr,1024+16);
  21.    BufSeg := Seg(BufPtr^) + ((Ofs(BufPtr^)+15) SHR 4);
  22.    RetCode := SioRxBuf(COM1, BufSeg, Size1024);
  23.    if SioInfo('I') > 0 then
  24.      begin
  25.        (* setup 128 transmit buffer *)
  26.        GetMem(BufPtr,128+16);
  27.        BufSeg := Seg(BufPtr^) + ((Ofs(BufPtr^)+15) SHR 4);
  28.        RetCode := SioTxBuf(Port, BufSeg, Size128);
  29.      end;
  30.    (* reset port *)
  31.    RetCode := SioReset(COM1,Baud9600);
  32.    (* was port reset ? *)
  33.    if RetCode <> 0 then
  34.      begin
  35.         write('Cannot reset COM1: ');
  36.         SioError(RetCode);
  37.         Halt;
  38.      end;
  39.    (* begin terminal loop *)
  40.    writeln('Enter terminal loop ( Type ^Z to exit )');
  41.    while TRUE do
  42.       begin
  43.          (* anything incoming over serial port ? *)
  44.          RetCode := SioGetc(COM1,0);
  45.          if RetCode > -1 then Write( chr(RetCode) );
  46.          (* has user pressed keyboard ? *)
  47.          if KeyPressed then
  48.             begin
  49.                (* read keyboard *)
  50.                Byte := ReadKey;
  51.                (* quit if user types ^Z *)
  52.                if Byte = chr($1a) then
  53.                   begin
  54.                      writeln('User typed ^Z');
  55.                      RetCode := SioDone(COM1);
  56.                      Halt;
  57.                   end;
  58.                (* send out over serial line *)
  59.                RetCode := SioPutc(COM1, Byte );
  60.             end
  61.       end
  62. end.
  63.